﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using Windows8Accelerator.Core.Xaml.Helpers;

namespace Windows8Accelerator.Core.Xaml.Controls
{
    public class SuperListViewGroupPanelContainer : Grid
    {
        public SuperListViewGroupPanelContainer()
        {
            Loaded += SuperListViewGroupPanelContainer_Loaded;
        }

        void SuperListViewGroupPanelContainer_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            var superListView = this.GetParentOf<SuperListView>();
            if (superListView != null)
            {
                SetBinding(Grid.MarginProperty,
                    new Binding()
                    {
                        Path = new PropertyPath("ActualPanelMargin"),
                        Source = superListView
                    });
                SetBinding(GroupHeaderCommandProperty,
                    new Binding()
                    {
                        Path = new PropertyPath("GroupHeaderCommand"),
                        Source = superListView
                    });
            }
        }

        public ICommand GroupHeaderCommand
        {
            get { return (ICommand)GetValue(GroupHeaderCommandProperty); }
            set { SetValue(GroupHeaderCommandProperty, value); }
        }
        public static readonly DependencyProperty GroupHeaderCommandProperty =
            DependencyProperty.Register("GroupHeaderCommand", typeof(ICommand), typeof(SuperListViewGroupPanelContainer), new PropertyMetadata(null));
    }


}
